<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    <title>Form Layouts</title>
    <?php $this->load->view('library/header');?>
</head>
<style>
    .flex-x{
        display: flex;
        flex-direction: row
    }
    .flex-y{
        display: flex;
        flex-direction: column;
    }
    .examine-box{
        display: none;
        height: 400px;
        width: 400px;
       border: 1px solid #DDDDDD;
        background-color: #f6f6f6;
        position: relative;
        top: -27px;
        right: 408px;
    }
    .Product-audit{
        line-height: 37px;
        padding-left: 40px;
        border-bottom: 1px solid #DDDDDD;
        background-color: #65CEA7;
    }
    .img{
        width: 127px;
        height: 113px;
        margin-left: 42px;
        margin-top: 20px;
    }
    .huohao{
        padding-left: 28px;
        padding-top: 50px;
    }
    .Result-box{
        margin-top: 10px;
    }
    .Result{

        padding: 5px 13px 5px 0px;
    }
    .adopt{
        cursor:pointer;
        margin-left: 37px;
        padding: 5px 13px;
        background-color: #5CB85C;
        color: white;
        border-radius: 5px;
    }
    .noadopt{
        cursor:pointer;
        margin-left: 37px;
        padding: 5px 13px;
        border-radius: 5px;
        color: #7A7676;
    }
    .fz700{
        font-weight: 700 !important;
    }
    .linh{
        line-height: 34px;
        padding: 0 !important;
    }
    .mtop10{
        margin: 15px 0 ;
    }
    .liyou{
        width: 90px;
        font-weight: 700 !important;
        padding-top: 33px;
    }
    .padiing-top{
        padding-top: 10px;
    }
    .pull-right{
        margin-top: 83px;
    }
    .mtop10{
        margin-left: 47px;
        margin-right: 15px;
    }
    .yuanyin{
        width: 68%;
        margin: 0 auto;
    }
    .fz1{
        margin-top: 115px;
    }
    .fz3{
        width: 140px !important;
    }
    .fz2{
        display: flex;
    }
</style>
<body  class="sticky-header">
<section>
    <?php $this->load->view('library/left');?>
    <div class="main-content" >
        <div class="zhezhao"></div>
        <?php $this->load->view('library/top');?>
        <div class="page-heading">
            <h3>待审核列表</h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Forms</a>
                </li>
                <li class="active"> Forms Layouts </li>
            </ul>
        </div>
<section class="wrapper">
    <section class="panel">
        <header class="panel-heading custom-tab turquoise-tab">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=1');?>" >待审核 (<?php echo $count;?>)</a>
                </li>
                <li class="cont-form">
                    <!-- <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=2');?>" >待补充</a> -->
                </li>
                <li class="">
                    <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=3');?>" >待编辑</a>
                </li>
                <li class="">
                    <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=4');?>" >上架审核</a>
                </li>

                <li class="cont-form">
                    <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=5');?>" >上架完成</a>
                </li>
                <li class="cont-form">
                    <a href="<?php echo base_url('PrepareGoods/index_accurate?prepare_state=6');?>" >回收站</a>
                </li>
            </ul>
        </header>
        <div class="panel-body">
            <div class="tab-content">
                <div class="tab-pane active" id="whole">
                    <?php $this->load->view('library/search');?>
                <section class="panel">
                        <div class="panel-body">
                            <div class="adv-table">
                                <table class="display table table-bordered table-striped" id="dynamic-table">
                                    <tr>
                                        <th width="3%">编号</th>
                                        <th width="5%">商品图片</th>
                                        <th width="10%">货号</th>
                                        <th width="5%" class="hidden-phone">开发员</th>
                                        <th width="6%" class="hidden-phone">商品分类</th>
                                        <th width="5%" class="hidden-phone">生产方式</th>
                                        <th width="5%" class="hidden-phone">渠道</th>
                                        <!-- <th width="5%" class="hidden-phone">备注</th> -->
                                        <th width="10%" class="hidden-phone">添加时间</th>
                                        <th width="5%" class="hidden-phone">操作</th>
                                    </tr>
                                    <?php foreach($prepare_accurate_list as $k=>$item){?>
                                        <tr class="gradeX">
                                            <td>
                                            <label>
                                                <input class="checkbox" value="<?php echo $item['prepare_id']?>"  name="goods_ids[]" type="checkbox"/><?php echo $item['prepare_id']?>
                                            </label>
                                            </td>

                                            <td>
                                                <img style="width: 100px;" class="img<?php echo $item['prepare_id']?>" src="<?php echo $item['original_img'];?>" />
                                            </td>

                                            <td>
                                                货号:<?php echo $item['goods_sn'];?><br>
                                                <div style="background-color: rgba(248, 206, 84, 0.98);width: 65px;margin-top: 30px;">
                                                    <span style="margin-left: 11px;color: aliceblue;" class="Awaiting-audit-btn">待审核</span>

                                                </div>
                                            </td>
                                            <td class="center hidden-phone">
                                                <?php echo $item['admin_name'];?>
                                            </td>
                                            <td class="hidden-phone">
                                                <?php echo $item['cate_name']?>
                                            </td>
                                            <td class="center hidden-phone">
                                                <?php echo $item['production_id'] == 1?'采买': '定制';?>
                                                
                                            </td>
                                            <td class="center hidden-phone">
                                                <?php echo $item['channel_id']?>
                                                
                                            </td>
                                            <td class="center hidden-phone"><?php echo $item['add_time'];?></td>
                                            <td class="hidden-phone">
                                                <a class="btn btn-xs btn-info examine log" data-id="<?php echo $item['prepare_id']?>" href="#rizhi" data-toggle="modal">操作日志</a><br>
                                                <a class="btn btn-xs btn-info shenhe_img" href="#myModal" data-goods_id="<?php echo $item['prepare_id']?>" data-toggle="modal">审核</a><br>

                                                <a class="btn btn-xs btn-info recovery" data-id="<?php echo $item['prepare_id']?>"  href="#huishou" data-toggle="modal">回收</a>

                                            </td>

                                        </tr>
                                    <?php }?>
                                    </tbody>
                                </table>
                                <div>
                                    <a class="btn btn-info all_examine allChoose">
                                        <span>全选</span ></a >
                                    <a class="btn btn-info all_examine cancelChoose">
                                        <span>取消全选</span >
                                    </a >
                                    <a class="btn btn-info all_examine" href="#myModal_all" data-toggle="modal">批量审核</a>
                                </div>
                            </div>
                            <div>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
<!--操作日志弹窗-->
<div class="modal fade" id="rizhi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">操作日志</h4></div>
            <div class="modal-body row log_show">
                    
            </div>
        </div>
    </div>
</div>
<!--审核弹窗-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">产品审核</h4></div>
            <div class="modal-body row ">
                <div class="col-md-5 img-modal">
                <img style="width: 200px;" class="t_img" src="" alt="">
                </div>
                <div class="col-md-7">
                    <!-- <p class=""><strong>产品货号:</strong> gw551545</p> -->
                    <div class="flex-x Result-box">
                        <p class="Result fz700">审核结果:</p>
                        <p class="adopt is_adopt" value="1">通过</p>
                        <p class="noadopt is_adopt" value="2">不通过</p>
                    </div>
                    <div class="form-group padiing-top">
                        <label class="col-sm-3 control-label linh fz700">选择理由:</label>
                        <div id="from_supp" class="col-sm-9 icheck minimal">
                            <select name="reason"  class="form-control">
                                <option value="0">请选择</option>
                                <?php foreach($reason as $k => $v){ ?>
                                    <option value="<?php echo $v?>"><?php echo $v;?></option>
                                <?php }?>
                                
                            </select>
                        </div>
                    </div>
                    <div class="form-group zidiyi">
                    <p class="liyou">自定义理由:</p>
                    <div id="" class="">
                    <input name="reason_text"   class="form-control" />
                    </div>
                    </div>
                    <input type="hidden" name="goods_id" >
                    <input type="hidden" name="is_adopt" value="1">
                    <div class="pull-right"><button class="btn btn-success btn-sm examine_one" type="button">审核</button></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--批量审核弹窗-->
<div class="modal fade" id="myModal_all" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">产品批量审核</h4></div>
            <div class="modal-body row ">
                <div class="col-md-3 img-modal">
                </div>
                <div class="col-md-7">
                    <!-- <p class=""><strong>产品货号:</strong> gw551545</p> -->
                    <div class="flex-x Result-box">
                        <p class="Result fz700">审核结果:</p>
                        <p class="adopt is_adopt" value="1">通过</p>
                        <p class="noadopt is_adopt" value="2">不通过</p>
                    </div>
                    <div class="form-group padiing-top">
                        <label class="col-sm-3 control-label linh fz700">选择理由:</label>
                        <div id="from_supp" class="col-sm-9 icheck minimal">
                            <select name="reason"  class="form-control">
                                <option value="0">请选择</option>
                                <?php foreach($reason as $k => $v){ ?>
                                    <option value="<?php echo $v?>"><?php echo $v;?></option>
                                <?php }?>
                                
                            </select>
                        </div>
                    </div>
                    <div class="form-group zidiyi">
                    <p class="liyou">自定义理由:</p>
                    <div id="" class="">
                    <input name="reason_text"   class="form-control reason_text" />
                    </div>
                    </div>
                    <input type="hidden" name="goods_id" >
                    <input type="hidden" name="is_adopt" value="1">
                    <div class="pull-right"><button class="btn btn-success btn-sm examine_all" type="button">审核</button></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--回收弹窗-->
<div class="modal fade" id="huishou" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"><h4 class="modal-title">回收</h4></div>
            <div class="modal-body row fz2">
                <div class="col-md-5 img-modal">
                    <img style="width: 200px;" class="h_img fz3" src="" alt="">
                </div>

                    <div class="form-group zidiyi yuanyin">
                        <p class="liyou">回收原因:</p>
                        <div id="" class="">
                            <input name="reason_reason"   class="form-control" />
                        </div>
                    </div>
                    <input type="hidden" name="examine_goods_id" >
                    <div class="pull-right"><button class="btn btn-success btn-sm recovery_sure fz1" type="button">确定</button></div>
                </div>
            </div>
        </div>
    </div>
</div>
</section>
</section>
</div>
</section>
<?php $this->load->view('library/footer');?>
<script src="/public/js/scripts.js"></script>
<script>
    // 全选
    $('.allChoose').click(function () {
        $('.checkbox').attr("checked", true)
    });
    //取消全选
    $('.cancelChoose').click(function () {
        $('.checkbox').attr("checked", false)
    });
    //批量审核
    $('.examine_all').click(function(){
        var all_id = ''
        $("input:checked").each(function() {
            all_id += "," + $(this).val() ;
        });
        var is_adopt = $("input[name='is_adopt']").val();
        var reason_text = $(".reason_text").val();
        $.ajax({
            type:'post',
            url:"<?php echo base_url('PrepareGoods/all_examine')?>",
            data:{
                all_id:all_id,
                is_adopt:is_adopt,
                reason_text:reason_text
            },
            success:function(msg){
                if(msg){
                    location.reload();
                }
            }
        })
    })
    //审核弹窗商品图片 和 goods_id 赋值
    $('.shenhe_img').click(function(){
        var goods_id = $(this).data('goods_id');
        var img = $('.img'+goods_id).attr('src');
        
        $('.t_img').attr('src',img)
        $("input[name='goods_id']").val(goods_id);
    })
    
    // 点击通过
    $(".adopt").click(function () {
        $(this).next(".noadopt").css("background-color","white");
        $(this).next(".noadopt").css("color","#7A7676");
        $(this).css("background-color","#5CB85C")
        $(this).css("color","white")
    });
    // 点击不通过
    $(".noadopt").click(function () {
        $(this).prev(".adopt").css("background-color","white");
        $(this).prev(".adopt").css("color","#7A7676");
        $(this).css("background-color", "#5CB85C")
        $(this).css("color","white")
    })
    //操作日志
    $('.log').click(function(){
        var id = $(this).data('id');
        $.ajax({
            type:'post',
            url:"<?php echo base_url('PrepareGoods/select_log')?>",
            dataType:'json',
            data:{
                id:id
            },
            success:function(obj){
                var h = '';
                $.each(obj,function(i,n){
                   h += "<p class='mtop10'>"+n.add_time+" 【"+n.admin_id+"】 "+n.examine_type+"</p>";
                })
                $('.log_show').html(h);
            }
        })
    })
    //通过不通过选择
    $('.is_adopt').click(function(){
        var adopt = $(this).attr('value');
        $("input[name='is_adopt']").val(adopt);
    })
    //理由选择
    $("select[name='reason']").change(function(){
        var val = $(this).val();
        $("input[name='reason_text']").val(val+':');
    })
    //审核
    $('.examine_one').click(function(){
        $(this).attr("disabled","disabled");
        var goods_id = $("input[name='goods_id']").val();
        var is_adopt = $("input[name='is_adopt']").val();
        var reason_text = $("input[name='reason_text']").val();
        $.ajax({
            type:'post',
            url:"<?php echo base_url('PrepareGoods/examine_goods')?>",
            data:{
                goods_id:goods_id,
                is_adopt:is_adopt,
                reason_text:reason_text
            },
            success:function(msg){
                if(msg){
                    location.reload();
                }
            }
        })
    })
    //回收赋值
    $('.recovery').click(function(){
        var goods_id = $(this).data('id');
        var img = $('.img'+goods_id).attr('src');
        $('.h_img').attr('src',img)
        $("input[name='examine_goods_id']").val(goods_id);
    })
    //回收
    $('.recovery_sure').click(function(){
        var reason_reason = $("input[name='reason_reason']").val();
        var goods_id = $("input[name='examine_goods_id']").val();
        $.ajax({
            type:'post',
            url:"<?php echo base_url('PrepareGoods/recovery')?>",
            data:{
                goods_id:goods_id,
                reason_reason:reason_reason,
            },
        success:function(msg){
            if(msg){
                    location.reload();
                }
        }
        })
    })
   
</script>
</body>
</html>
